import '../public.dart';
import 'base_model.dart';

/// 章节弹幕
class ChapterBarrageModel extends BaseModel {
  int comicId; // 漫画id
  int chapterId; // 章节id
  int imageIndex; // 图片序号
  String text; // 内容
  String fontColor; // 字体颜色
  int isVIP; // 是否vip
  int uId; // 用户id
  int isTop; // 是否置顶
  bool isShowing = false; // 是否正在显示
  int showCount = 0; // 显示过的次数

  ChapterBarrageModel(
      {this.comicId,
      this.chapterId,
      this.text,
      this.imageIndex,
      this.uId,
      this.fontColor,
      this.isVIP});

  ChapterBarrageModel.fromJson(Map<String, dynamic> data)
      : super.fromJson(data);

  ChapterBarrageModel.fromData(
      Map<String, dynamic> data, int pageIndex, ChapterModel chapter)
      : super.fromJson(data) {
    chapterId = chapter.id;
    comicId = chapter.comicModel.id;
    imageIndex = pageIndex;
    text = data["msg"];
    fontColor = data["fontColor"];
    isVIP = data["isVIP"];
    uId = data["uId"];
    isTop = data["isTop"];
  }

  @override
  Map<String, dynamic> toJson() {
    return {'chapterId': chapterId, 'text': text};
  }
}
